#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>

int main(int argc,char *argv[])
{
	
	if(argc != 2)
	{
		printf("command path\n");
		exit(-1);
	}
	DIR	*dir = NULL;
	struct dirent *dent = NULL;

	dir = opendir(argv[1]);
	if(dir == NULL)
	{
		perror("opendir");
		exit(-1);
	}

	dent = readdir(dir);
	while(dent != NULL)
	{
		//printf("%s %d\n ",dent->d_name,dent->d_type);
		if(dent->d_type == DT_DIR)
			printf("%s is directory\n",dent->d_name);
		else if(dent->d_type == DT_REG)
			printf("%s is normal file\n",dent->d_name);
		dent = readdir(dir);
	}


	/*
	dent = readdir(dir);
	printf("%s\n",dent->d_name);
	dent = readdir(dir);
	printf("%s\n",dent->d_name);*/

	closedir(dir);

	return 0;
}
